Repository navigation
Fix StaticCredentials refresh for short-lived JWTs - #945
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #945 +/- ##
=======================================
Coverage 82.70% 82.70%
=======================================
Files 99 99
Lines 12960 12965 +5
Branches 1266 1266
=======================================
+ Hits 10718 10723 +5
Misses 1789 1789
Partials 453 453
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change includes synchronous and asynchronous coverage for JWT-based expiration and short-lived token refresh behavior.
No open issues 🎉
What changed in this PR
This pull request updates StaticCredentials to derive token lifetime from the login JWT's exp claim, ensuring short-lived tokens are refreshed before expiration.
Changes:
- Calculate token lifetime from the JWT expiration claim.
- Cap clock-skew protection at one tenth of the remaining lifetime.
- Apply the shared expiration logic to synchronous and asynchronous credentials.
- Add coverage for short-lived token caching and refresh behavior.
- Document the fix in the changelog.
| File | Description |
|---|---|
| ydb/credentials.py | Derives token lifetime from JWT expiration and adjusts shared expiration protection for short-lived tokens. |
| tests/auth/test_static_credentials.py | Tests JWT-based expiration handling and synchronous short-lived token refresh behavior. |
| tests/aio/test_credentials.py | Tests asynchronous caching and refresh behavior for short-lived tokens. |
| CHANGELOG.md | Documents the short-lived token refresh fix. |
Review effort: Lite
KirillKurdyukov
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StaticCredentials now derives the token lifetime from the login JWT's
expclaim instead of assuming 30 minutes, so short-lived tokens are refreshed before they expire.Cap the clock-skew allowance at one tenth of the remaining lifetime so tokens shorter than 30 seconds can be cached. The shared calculation applies to synchronous and asynchronous credentials.
Fixes #943.